Dokumentation anzeigen (2)

Update für die Anzeige der Dokumentation im Docking Container. Die Routine wurde erweitert und HTML so aufbereitet, dass die Doku wie die SAP-Dokumentation aussieht.

In dieser Version stelle ich Ihnen eine fertige Methode vor, die nur noch im Zeitpunkt 19 des Tabellenpflegedialoges oder in Zeitpunkt 03 des Viewclusters eingebunden werden muss.

Die Aufbereitung erfolgt analog zu der SAP-Doku und sieht “etwas schicker” aus:

Zusätzlich kann eine alternative Dokumentation übergeben werden, die angezeigt wird, wenn die Doku zur Tabelle nicht vorhanden ist.

Vorbereitungen

Methode anlegen

Legen Sie sich eine Klasse, wie z.B. ZCL_MAINTENANCE_TOOLS an und implementieren Sie die statische PUBLIC-Methode SHOW_DOCU:

Importing-Parameter:

  • IV_TABLE TYPE C “Tabellenname”
  • IV_ALDOC  TYPE C “Alternative Dokumentation SE61”

Globale Attribute

Legen Sie folgende statische private Attribute an:

GR_DOCK    Type Ref To CL_GUI_DOCKING_CONTAINER
GR_HTML    Type Ref To CL_GUI_HTML_VIEWER
GV_TABLE   Type C

Aufruf Tabellenpflegedialog

Zeitpunkt 19

  CALL METHOD zcl_maintenance_tools=>show_docu
EXPORTING
iv_table = vcl_akt_view
iv_aldoc = ‘ZZT_ALTDOC_TABLE_ZZABC’.

Aufruf Viewcluster

Zeitpunkt 03

  IF master_name = x_header-viewname.
CALL METHOD zcl_maintenance_tools=>show_docu
EXPORTING
iv_table = x_header-viewname.
ENDIF.

HINWEIS:
Die alternative Dokumentation muss in der SE61 als “Text im Dialog” angelegt werden.

Eigene Anpassungen

Leider werden in den gerufenen Standard-Routinen nicht alle HTML-Tags “schön” angepasst. Die Tabellendefinitionen werden zum Beispiel nicht geändert.

Hier kann man aber manuell einfach Abhilfe schaffen:

*** set table cells to size 2
      REPLACE ALL  OCCURRENCES OF '<td>' IN TABLE lt_html
         WITH '<td><font FACE="Arial" SIZE=2>'.        
*** set table border "dashed" and grey background
      REPLACE ALL  OCCURRENCES OF '<table>' IN TABLE lt_html
         WITH '<table style="border:thin dashed blue" width="100%" cellpadding=3 bgcolor=#E0E0E0>'.

Das Ergebnis sieht dann so aus:

Coding

METHOD show_docu.

*** Local data
  DATA lt_lines            TYPE STANDARD TABLE OF tline.
  DATA ls_header           TYPE thead.
  DATA lt_html             TYPE STANDARD TABLE OF  htmlline.
  DATA lv_url              TYPE c LENGTH 500.
  DATA lv_table            TYPE doku_obj.
  DATA lv_spras            TYPE sylangu.
  DATA lt_conv_charformats TYPE TABLE OF tline.
  DATA lt_conv_parformats  TYPE TABLE OF tline.


*** has anything changed??
  CHECK gv_table <> iv_table.

  lv_table = iv_table.

***  Read table docu
  CALL FUNCTION 'DOCU_GET'
    EXPORTING
      id     = 'TB'
      langu  = sy-langu
      object = lv_table
    IMPORTING
      head   = ls_header
    TABLES
      line   = lt_lines
    EXCEPTIONS
      OTHERS = 5.
  IF sy-subrc > 0.
*** try other language
    CASE sy-langu.
      WHEN 'D'.
        lv_spras = 'E'.
      WHEN 'E'.
        lv_spras = 'D'.
      WHEN 'F'.
        lv_spras = 'E'.
    ENDCASE.
*** read docu in other language
    CALL FUNCTION 'DOCU_GET'
      EXPORTING
        id     = 'TB'
        langu  = lv_spras
        object = lv_table
      IMPORTING
        head   = ls_header
      TABLES
        line   = lt_lines
      EXCEPTIONS
        OTHERS = 5.
  ENDIF.

***  Read alternative docu
  IF lt_lines IS INITIAL AND iv_aldoc IS NOT INITIAL.
*** read alternative docu (Dialog Text)
    lv_table = iv_aldoc.
    CALL FUNCTION 'DOCU_GET'
      EXPORTING
        id     = 'DT'
        langu  = sy-langu
        object = lv_table
      IMPORTING
        head   = ls_header
      TABLES
        line   = lt_lines
      EXCEPTIONS
        OTHERS = 5.
    IF sy-subrc > 0.
*** read alternative docu (Dialog Text) in different language
      CALL FUNCTION 'DOCU_GET'
        EXPORTING
          id     = 'DT'
          langu  = lv_spras
          object = lv_table
        IMPORTING
          head   = ls_header
        TABLES
          line   = lt_lines
        EXCEPTIONS
          OTHERS = 5.

    ENDIF.
  ENDIF.

*** _______________________________________________________________ ***
***                                                                 ***
***  Build controls
*** _______________________________________________________________ ***
***                                                                 ***

  IF gr_dock IS INITIAL.
*** create docking container
    CREATE OBJECT gr_dock
      EXPORTING
        side                    = cl_gui_docking_container=>dock_at_right
        extension               = 400
        no_autodef_progid_dynnr = 'X'.
  ENDIF.


  IF lt_lines IS INITIAL.
*** No doku: Set controls to invisible
    IF gr_html IS BOUND.
      CALL METHOD gr_html->set_visible
        EXPORTING
          visible = space.
    ENDIF.

    IF gr_dock IS BOUND.
      CALL METHOD gr_dock->set_visible
        EXPORTING
          visible = space.
    ENDIF.
  ELSE.
*** Doku exists: Set controls visible
    IF gr_html IS BOUND.
      CALL METHOD gr_html->set_visible
        EXPORTING
          visible = 'X'.
    ENDIF.
    IF gr_dock IS BOUND.
      CALL METHOD gr_dock->set_visible
        EXPORTING
          visible = 'X'.
    ENDIF.
  ENDIF.


  IF lt_lines IS NOT INITIAL.
*** doku exists:
    IF gr_html IS INITIAL.
*** Create HTML-Control
      CREATE OBJECT gr_html
        EXPORTING
          parent = gr_dock.
    ENDIF.

*** _______________________________________________________________ ***
***                                                                 ***
***  Convert character and parameter formats
*** _______________________________________________________________ ***
***                                                                 ***
    IF lt_conv_parformats IS INITIAL.
      PERFORM build_mapping_tables   IN PROGRAM rshtmimg_2
       TABLES lt_conv_charformats
              lt_conv_parformats.
    ENDIF.

*** _______________________________________________________________ ***
***                                                                 ***
***  Convert Docu to HTML
*** _______________________________________________________________ ***
***                                                                 ***

    CALL FUNCTION 'CONVERT_ITF_TO_HTML'
      EXPORTING
        i_header           = ls_header
      TABLES
        t_itf_text         = lt_lines
        t_html_text        = lt_html
        t_conv_charformats = lt_conv_charformats
        t_conv_parformats  = lt_conv_parformats
      EXCEPTIONS
        syntax_check       = 1
        replace            = 2
        illegal_header     = 3
        OTHERS             = 4.
    IF sy-subrc = 0.

*** Convert Tables
      PERFORM convert_tables IN PROGRAM rshtmimg_2 TABLES lt_html.
*** Set colours (Make text look like SAP documentation)
      PERFORM set_colors     IN PROGRAM rshtmimg_2 TABLES lt_html.

*** Push data to control
      CALL METHOD gr_html->load_data
        IMPORTING
          assigned_url = lv_url
        CHANGING
          data_table   = lt_html
        EXCEPTIONS
          OTHERS       = 4.

      IF sy-subrc = 0.
*** _______________________________________________________________ ***
***                                                                 ***
***  Display HTML-Text
*** _______________________________________________________________ ***
***                                                                 ***

        CALL METHOD gr_html->show_url
          EXPORTING
            url = lv_url.
      ENDIF.
    ENDIF.
  ENDIF.

ENDMETHOD.

 

Enno Wulff
Letzte Artikel von Enno Wulff (Alle anzeigen)

Leave a Comment